package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.domain.req.documentAttachment.ListDocumentAttachmentRequest;
import com.xy.biz.fd.domain.req.documentAttachment.SaveDocumentAttachmentRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.fd.domain.bo.DocumentAttachmentBO;
import com.xy.biz.fd.domain.po.DocumentAttachmentPO;
import com.xy.biz.fd.domain.query.DocumentAttachmentQuery;
import com.xy.biz.fd.domain.resp.GetDocumentAttachmentResponse;

/**
 *
 *
 * @author wcs
 * @date 2021-2-19
 */
public class DocumentAttachmentConverter {

	public static DocumentAttachmentPO toPO(DocumentAttachmentBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentAttachmentPO(), true);
	}

	public static List<DocumentAttachmentPO> toPO(Collection<DocumentAttachmentBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentAttachmentPO(), true);
	}

	public static DocumentAttachmentBO fromPO(DocumentAttachmentPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentAttachmentBO());
	}

	public static List<DocumentAttachmentBO> fromPO(Collection<DocumentAttachmentPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentAttachmentBO());
	}

	public static DocumentAttachmentBO toBO(SaveDocumentAttachmentRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentAttachmentBO(), true);
	}

	public static List<DocumentAttachmentBO> toBO(Collection<SaveDocumentAttachmentRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentAttachmentBO(), true);
	}

	public static GetDocumentAttachmentResponse toResponse(DocumentAttachmentBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentAttachmentResponse());
	}

	public static List<GetDocumentAttachmentResponse> toResponse(Collection<DocumentAttachmentBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentAttachmentResponse());
	}

	public static DocumentAttachmentQuery toQuery(ListDocumentAttachmentRequest source) {
		if(null == source) {
			return null;
		}
		DocumentAttachmentQuery target = new DocumentAttachmentQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
